<!DOCTYPE html>


<html xmlns:th="http://www.thymeleaf.org">

<head th:replace="layouts::header">
</head>

<body>

<nav th:replace="layouts::navbar"></nav>
<div>
    <h3>&nbsp</h3>
</div>

<div class="container">
    <form th:action="@{/borrows/save}" th:object="${borrow}" method="POST" >

        <input type="hidden" th:field="${borrow.borrowId}">

        <select style="display: none" th:field="*{name}">
            <option th:each="student : ${allStudents}" th:value="${student.name}" th:text="${student.name}">
        </select>
        <textarea th:each="student : ${allStudents}" th:text="${student.name}"></textarea>

        <!--        <textarea type="text" disabled id="name1" th:field="${borrow.name}"></textarea>-->
<!--        <textarea type="text" disabled id="name2" th:each="student : ${allStudents}" th:value="${student.name}" th:text="${student.name}"></textarea>-->

        <div class="down">
            <textarea type="text" placeholder="输入项目描述" th:field="${borrow.description}"></textarea>
        </div>
        <div class="down">
            <textarea type="text" id="time" th:field="${borrow.author}"></textarea>
        </div>

            <select style="display: none"  th:field="*{books}" >
                <option th:each="book : ${allBooks}" th:value="${book.bookId}"  th:text="${book.name}" ></option>
            </select>
        </div><br>
        <input type="hidden" name="_csrf" th:value="${_csrf.token}">
        <button type="submit">新建项目</button>
    </form>
</div>

<script>
    // document.getElementById("name1").value =document.getElementById("name2").textContent;
    Date.prototype.format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
    var day = new Date();
    document.getElementById("time").value =day.format("yyyy-MM-dd hh:mm:ss");
</script>
</body>
</html>